from sanic import Sanic
from sanic.response import json

from bert_serving.client import BertClient
# ip address of the GPU machine
bc = BertClient(ip='m2.moono.vip')



app = Sanic("hello_example")





@app.route("/save")
async def test(request):
    myreq = request.get_args(keep_blank_values=True)
    str = myreq["string"][0]
    myid = myreq["myid"][0]
    myid2 = int(myid)
    s_encode = bc.encode([str])
    a = s_encode[0].tolist()
  

    return json({"hello": a})

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000, auto_reload=True)
